<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理后台</title>
    <link href="/favicon.ico" type="image/x-icon" rel="shortcut icon" />
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    
    <link href="/public/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/css/ratuo.css" rel="stylesheet">
    <!-- jQuery 2.1.4 -->
    <script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/public/admin/js/myFormValidate.js"></script>
    <script src="/public/admin/js/common.js"></script>
    <script src="/public/admin/js/myAjax.js"></script>
    <script src="/public/admin/js/article.js"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script>
    <script src="/public/admin/js/jquery.validate.js"></script>

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>前台导航</h5>
                </div>
                <div class="ibox-content">
                    <div class="box-header">
                        <div class="panel-body">
                            <a href="javascript:history.go(-1)" class="btn btn-primary"><i class="fa fa-plus"></i>返回</a>
                        </div>                  
                    </div><!-- /.box-header -->
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-1"> 基本信息</a></li>
                    </ul>
                    <br/>
                    <div class="row">
                        <!--表单数据-->
                        <form class="form-horizontal" method="post" id="addEditNavForm"  onsubmit="return checkName();">
                            <div class="tab-content">
                                <div id="tab-1" class="tab-pane active">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">父级导航：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="parent_id">
                                            <option value="0">顶级</option>
                                            <?php echo $cat_select ?>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">导航名称：</label>
                                        <div class="col-sm-8">
                                            <input class="configInput form-control" name="name" minlength="2" type="text" value="{$navigation.name}" required="" aria-required="true">
                                            <span id="err_name" style="color:#F00; display:none;">导航名称不能为空!!</span>
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">导航名称(英)：</label>
                                        <div class="col-sm-8">
                                            <input class="configInput form-control" name="e_name" minlength="2" type="text" value="{$navigation.e_name}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">导航类型：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="type" id="AdsType" onchange="ChangeType()">
                                                <option value="3" {if $navigation['type'] == 3}selected="selected"{/if} >自定义链接</option>
                                                <option value="1" {if $navigation['type'] == 1}selected="selected"{/if} >文章列表</option>
                                                <option value="2" {if $navigation['type'] == 2}selected="selected"{/if}>产品列表</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group" id="adstype_1">
                                        <label class="col-sm-2 control-label">文章栏目：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="cate_id" id="">
                                                <?php echo $article_kind ?>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group" id="adstype_2">
                                        <label class="col-sm-2 control-label">产品栏目：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="category_id" id="">
                                                <?php echo $product_kind ?>
                                            </select>
                                        </div>
                                    </div>
                                    <div id="adstype_3">
                                        <div class="form-group" id="">
                                            <label class="col-sm-2 control-label">导航链接：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" type="text" value="{$navigation.url}" name="url" />
                                            </div>
                                        </div>
                                        <!-- <div class="form-group" id="">
                                            <label class="col-sm-2 control-label">手机链接：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" type="text" value="{$navigation.p_url}" name="p_url" />
                                            </div>
                                        </div> -->
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">导航图片：</label>
                                        <div class="col-sm-8">
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="image" id="image" value="{$navigation.image}"> <span class="input-group-btn"> <button type="button" class="btn btn-primary" onclick="BrowseServer('image');">选择图片</button> </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">排序：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$navigation.sort|default='90'}" name="sort" class="configInput form-control" placeholder=""/>   
                                            <!-- <input class="configInput form-control" type="text" value="{$navigation.url}" name="url" /> -->
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label"></label>
                                        <div class="col-sm-8">
                                            <input type="hidden" name="id" value="{$navigation.id}">
                                            <button class="btn btn-primary" title="" data-toggle="tooltip" type="submit" data-original-title="保存">保存</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
// 判断输入框是否为空
function checkName(){
	var name = $("#addEditNavForm").find("input[name='name']").val();
    if($.trim(name) == '')
	{
		$("#err_name").show();
		return false;
	}
	return true;
}
        function ChangeType() {
            var styles, key, val;
            val = $('#AdsType').val();
            styles = new Array('1', '2', '3');
            for (key in styles) {
                if (styles[key] == val) {
                    $("#adstype_" + styles[key]).removeClass('hide');
                } else {
                    $("#adstype_" + styles[key]).addClass('hide');
                }
            }
        }
// 更改系统内容
$("#system_nav").change(function(){	
	var text = $(this).find("option:selected").text();
	text = text.replace(/-/ig,""); 
	var val  = $(this).find("option:selected").val();	
	$("input[name='name']").val(text);
	$("input[name='url']").val(val);	
});
$(function () {
    ChangeType();
})
</script>

</body>
</html>